<?php
$loginmanager = new loginmanager();
$show_site = $loginmanager->allowed_is("Administrator");
if($show_site)
{
	$log = "";
	$usermanager = new usermanager();
	if(isset($_POST["change_rang"], $_POST["id"]))
	{
		if(is_numeric($_POST["id"]))
		{
			$usermanager->change_state($_POST["change_rang"], $_POST["id"]);
			$log = $usermanager->log->get_log();
		}
	}
	if(isset($_GET["action"], $_GET["id"]))
	{
		if(is_numeric($_GET["id"]))
		{
			if($_GET["action"] == "activate")
			{
				$usermanager->activate_user($_GET["id"]);
			}
			if($_GET["action"] == "deactivate")
			{
				$usermanager->deactivate_user($_GET["id"]);
			}
			if($_GET["action"] == "delete")
			{
				$usermanager->delete_user($_GET["id"]);
			}
			$log = $usermanager->log->get_log();
		}
	}
	if(isset($_POST["id"], $_POST["username"])) {
		$usermanager->edit_name();
		$log = $usermanager->log->get_log();
	}
	echo string::get_in_header_style("Benutzerverwaltung");
	echo "<form action=\"index.php?page=user\" method=\"post\">
			<label>Filter: </label>
			<select id=\"filter\" name=\"filter\">
			<option value=\"\"></option>
			<option value=\"Administrator\">Administrator</option>
			<option value=\"Moderator\">Moderator</option>
			<option value=\"Benutzer\">Benutzer</option>
			</select>
			</form><br />";
	$filter = "";
	if(isset($_POST["filter"])) {
		if(!empty($_POST["filter"])) {
			if($_POST["filter"] == "Administrator" || $_POST["filter"] == "Moderator" || $_POST["filter"] == "Benutzer")
			{
				$filter = "WHERE rang='".$_POST["filter"]."'";
			}
		}
	}
	$usermanager->get_user_in_table_by_rang("class=\"user_table\" cellspacing=\"0px\" cellpadding=\"0px\"", "class=\"user_header_row\"", $filter);// WHERE rang = 'Administrator'
	echo $log;
}
?>